<template>
<!-- 自动审批 -->
  <div class="box">
      <van-row class="automayic_top">
          <span>开启自动审核</span>
          <van-switch v-model="checked" @change="show_check"/>
      </van-row>
      <van-row v-show="show">
          <van-field v-model="number" type="number" label="自动审核时长" />
      </van-row>
      <van-row>
          <i style="font-size:12px;font-style:normal;color:silver">开启自动审核后，事件初审通过后终审会在设置的审核时间进行自动审核(自动审核默认为1可进行修改1到24小时)</i>
      </van-row>
      <van-button
      round
      :style="{width:'95%',height:'5.5vh',lineHeight:'5.5vh',position:'fixed',right:'8px',bottom:'55px'}"
      color="#3C9BFB"
      @click="Submission"
    >提交</van-button>
  </div>
</template>

<script type="text/javascript">
import { row ,Switch ,Button,Field  } from "vant";
export default {
  data() {
    return {
        checked:false,
        number:1,
        show:false,
        isAutomatic:0,
    }
  },
  methods:{
      show_check(){
        if(this.checked==true){
            this.show=true;
            this.isAutomatic=1
            // this.Submission()
        }else{
             this.show=false;
             this.isAutomatic=0
            //  this.Submission()
        }
      },
      async Submission(){
             let corpId = localStorage.getItem("custid");
        //   let corpId = this.$utils.getUrlKey("custid");
          let userId = localStorage.getItem('userId')
          const num=this.isAutomatic;
          const i=this.number ;
          if(i>=0&&i<=24){
              const res = await this.$http.get(`yuepoints/setAutomaticAudit?corpId=${corpId}&userId=${userId}&isAutomatic=${num}&Duration=${i}`)
              if(res.data.errcode!='0000'){
                  this.$toast(res.data.errmsg)
              }  
          }else{
              this.$toast('时长在1-24')
          }
        
      }
  },
  components: {
      [row.name]:row,
      [Switch.name]:Switch,
      [Button.name]:Button,
      [Field.name]:Field  
  }
}
</script>

<style lang="less" scoped>
.box{
    font-size: 15px;
    /deep/ .van-switch {
        vertical-align: middle;
        float: right;
        margin-top: 10px;
    }
    /deep/ .van-field__value{
        margin-left: 60vw;
    }
    .automayic_top{
        height: 50px;
        background: #fff;
        line-height: 50px;
        text-align: left;
        padding:0px 15px;
    }
    // .right{
    //     float: right;
    // }
}
</style>
